<%@ page pageEncoding="UTF-8"%>
<%@ taglib prefix="isperp" uri="/WEB-INF/tlds/isperp.tld"%>

<script type="text/javascript">
   var clickTreeId="";
   function setting()
   {
      isperp.openDialog({
			title : '设置',
			contentUrl : "incident/categoryPropertySetting/settingEdit?categoryId=" + clickTreeId
		});
   }

	function categoryTree_onNodeClick(event, treeId, treeNode) {
		//alert(treeNode.treenodePath);
		//alert(	JSON.stringify(treeNode));
		/**/
		categoryPropertyGrid.search({
			"field" : "categoryId",
			"op" : "eq",
			"data" : treeNode.id
		});
		clickTreeId=treeNode.id;

	}

	function getCategoryTreeNode() {
		var node = incidentCategoryTree.zTree.getSelectedNodes();

		if (node && node != "") {
			return "categoryId=" + node[0].id;
		}

		alert("请选择一个节点");
		return false;
	};

	function category_BeforeDeleteFun(treeNode) {

		var result = "";
		$.ajax({
			type : "POST",
			url : "incident/category/property/getPropertyCountByCategoryPath",
			data : "categoryPath=" + treeNode.treenodePath,
			dataType : "json",
			success : function(data) {
				if (data > 0) {

					result = "资产类别或子类别下存在自定义属性，您确定要全部删除？";
				}

			},
			async : false
		});
		
		return result;
	}
</script>
<div class="box no-border container_0 clearfix">
	<div class="box-left" style="width:20%">
		<isperp:tree title="事件分类" modal="false" id="incidentCategoryTree"
			cusEditUrl="incident/category/edit"
			cusDeleteUrl="incident/category/delete">
			<isperp:async enable="true" url="incident/category/getTree?showRoot=1">
			</isperp:async>
			<isperp:callback onClick="categoryTree_onNodeClick">
			</isperp:callback>
			<isperp:edit enable="true" showRemoveBtn="false"
				showRenameBtn="false"></isperp:edit>
			<isperp:view showTitle="false" addHoverDom="true"
				removeHoverDom="true"></isperp:view>
		</isperp:tree>
	</div>
	<div class="box-right" style="width:75%">
		
		
		<div class="header">
					<h2>分类自定义属性</h2>
				</div>
				<isperp:grid url="incident/category/property/listByCategory"
					gridId="categoryPropertyGrid" cusFormatterActions="true"
					showPager="false" showSearchbar="false" cusDialogSize="normal"
					cusEditUrl="incident/category/property/edit"
					cusDeleteUrl="incident/category/property/delete"
					ondbClickRowEvent="categoryPropertyGrid.edit(rowid);"
					beforeCreateAction="getCategoryTreeNode();" >

					<jsp:attribute name="toolbar">
	 				<isperp:toolbar id="categoryPropertyToolbar">
						<isperp:button id="categoryCreate" icon="icon-plus" text="新增分类属性"
								onclick="categoryPropertyGrid.create();"></isperp:button>
						<isperp:button id="categorySetting" icon="icon-plus" text="设置"
								onclick="setting()"></isperp:button>
	 				</isperp:toolbar>
				 	</jsp:attribute>
					<jsp:body> 
					<isperp:column name="id" title="ID" ></isperp:column> 
					<isperp:column name="parent_treenode_name_path" title="所属分类"
							width="120">
					</isperp:column>
					<isperp:column name="name" title="属性名称" width="100">
					</isperp:column>
					<isperp:column name="data_type" title="类型" width="70">
					</isperp:column>
					<isperp:column name="td_inner_html" title="td样式" width="70">
					</isperp:column>
					<isperp:column name="default_value" title="默认值" width="70">
					</isperp:column>	
					<isperp:column name="notnull" title="必填项" width="50" align="center"
							formatter="checkbox">
			    	 </isperp:column>
			    	 
			    	 
					<isperp:column name="order_num" title="排序" width="50">
					</isperp:column>
				</jsp:body>

				</isperp:grid>
		
		
		<isperp:operate code="COMMON_TREE_HELP"></isperp:operate>

	</div>
</div>